package ca.concordia.comp6231.ros;

import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

import ca.concordia.comp6231.ros.udp.UDPServiceROS;

public class RequestOrderingService {
	
	private final static Logger logger = Logger.getLogger(RequestOrderingService.class.getName());
	private Thread udpService;
	
	public RequestOrderingService() {
		
		loadUDPService();
	}
	
	private void loadUDPService(){
		int udpPortNo = 7780;
		udpService = new Thread(new UDPServiceROS(udpPortNo, this));
		
		try{
			udpService.start();
			String message = " ROS started running UDP service at port: " +	udpPortNo + ".";
			logger.log(Level.INFO, message);
			System.out.println("[" + new Date(System.currentTimeMillis()) + "]" + message);
		}catch(Exception e){
			String message = " ROS failed to start UDP service at port: " + udpPortNo + ".";
			logger.log(Level.SEVERE, message);
			System.out.println("[" + new Date(System.currentTimeMillis()) + "]" + message);
		}		
	}
	
}
